import service, { CustomSuccessData } from './index';

interface IAxiosGet {
    <T = any>(url: string, params?: Record<string, any>, showLoading?: boolean | string): Promise<CustomSuccessData<T>>;
}
interface IAxiosPostOrPutOrDelete {
    <T = any>(url: string, data?: Record<string, any>, showLoading?: boolean | string): Promise<CustomSuccessData<T>>;
}
const get: IAxiosGet = (url, params, showLoading?: boolean | string) => {
    return service({ url: url, method: 'GET', params: params, showLoading: showLoading });
};
const post: IAxiosPostOrPutOrDelete = (url, data, showLoading?: boolean | string) => {
    return service({ url: url, method: 'POST', data: data, showLoading: showLoading });
};
const postForm: IAxiosPostOrPutOrDelete = (url, data, showLoading?: boolean | string) => {
    return service({
        url: url,
        method: 'POST',
        header: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        data: data,
        showLoading: showLoading
    });
};
const put: IAxiosPostOrPutOrDelete = (url, data, showLoading?) => {
    return service({ url: url, method: 'PUT', data: data, showLoading: showLoading });
};
const deleteRequest: IAxiosPostOrPutOrDelete = (url, data, showLoading?) => {
    return service({ url: url, method: 'DELETE', data: data, showLoading: showLoading });
};
export default {
    get,
    post,
    put,
    postForm,
    delete: deleteRequest
};
